<?php
namespace app\index\controller;
use think\Request;  
use think\controller\Rest; 
class Goods extends Rest{
    public function readAll(){
        if(input('param.type')!=null){
            $type=input('param.type');
            $search[$type]=1;
        }else{
            $search=(object)null;
        }
        $start=input('param.start')!=NULL?input('param.start'):0;
        $count=input('param.count')!=NULL?input('param.count'):10;
        $model = model('Goods');   
        $data=$model->where($search)->limit($start,$count)->order('id desc')->select();
        return json($data);  
    }
    public function read($id){  
        $model = model('Goods');   
        $data=$model->where('id', $id)->find(); 
        return json($data);  
    }
    public function readGoodstype(){
        $model = model('Goodstype');   
        $data=$model->select(); 
        return json($data);
    }
}